package com.zisuyi.game.sdk.net

import com.weilele.mvvm.utils.net.createRetrofitApi
import com.zisuyi.game.sdk.base.net.API_BASE_URL
import com.zisuyi.game.sdk.game.bean.UpOffwallBean
import com.zisuyi.game.sdk.library.login.IGameLogin
import com.zisuyi.game.sdk.net.bean.*
import com.zisuyi.game.sdk.net.bean.req.GameRewardReq
import com.zisuyi.game.sdk.net.bean.req.InviteReq
import com.zisuyi.game.sdk.net.bean.req.RedeemReq
import retrofit2.http.*

interface GameApi {
    companion object {
        internal val self by lazy {
//            createRetrofitApiWithResultCall<GameApi,BaseGameBean<*>>(API_BASE_URL){result, error, originalResult ->
//                println()
//            }
            createRetrofitApi<GameApi>(API_BASE_URL)
        }
    }

    /**
     * 用户登录
     */
    @POST("/api/v2/user/")
    suspend fun userLogin(@Body user: IGameLogin.UserInfo): BaseGameBean<UserInfoBean>

    /**
     * 兑换
     */
    @POST("/api/v2/order/")
    suspend fun redeem(@Body user: RedeemReq): BaseGameBean<RedeemBean>

    /**
     * 输入邀请码
     */
    @PUT("/api/v2/user/invite")
    suspend fun inviteCode(@Body req: InviteReq): BaseGameBean<InviteBean>

    /**
     * 兑换历史
     */
    @GET("/api/v2/order/")
    suspend fun redeemHistory(): BaseGameBean<MutableList<RedeemHistoryBean>>

    /**
     * 获取游戏信息
     */
    @GET("/api/v2/game/hamburger")
    suspend fun getGameInfo(): BaseGameBean<Any>

    /**
     * 根据游戏名，获取小游戏信息
     */
    @GET("/api/v2/game/{gameName}")
    suspend fun getSmallGameInfo(@Path("gameName") gameName: String): BaseGameBean<SmallGameInfoBean>

    /**
     * 根据游戏名，获取小游戏信息
     */
    @POST("/api/v2/game/{gameName}")
    suspend fun gameReward(
        @Path("gameName") gameName: String,
        @Body bean: GameRewardReq
    ): BaseGameBean<*>

    /**
     * 获取钻石奖励
     */
    @POST("/api/v2/game/hamburger")
    suspend fun upOffwallReward(@Body bean: UpOffwallBean): BaseGameBean<Any>

    /**
     * 获取兑换条件
     */
    @GET("/api/v2/order/condition")
    suspend fun redeemCondition(): BaseGameBean<MutableList<UserInfoBean.RedeemDTO.ConditionsDTO>>
}